package com.fire.control.system.module.warning.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.fire.control.system.dto.MaintenceListDTO;
import com.fire.control.system.dto.SelectWarningDescDTO;
import com.fire.control.system.dto.WarningHandleDTO;
import com.fire.control.system.dto.WarningInfoDto;
import com.fire.control.system.dto.app.AppRespWarningVo;
import com.fire.control.system.dto.app.AppWarningInfoVo;
import com.fire.control.system.entity.WarningInfo;
import com.fire.control.system.entity.WarningInfoHistory;
import com.fire.control.system.support.protocol.device.DeviceRequestProtocol;

public interface WarningMapper{
	
	/**
	* @Title: insertWarningInfoHistory
	* @Description: TODO(报警级别历史)
	* @author wanbo
	* @date  2017年6月16日 下午4:21:53
	* @return
	*/
	public int insertWarningInfoHistory(WarningInfoHistory WarningInfoHistory);
	
	
	/**
	* @Title: getWarningInfoLastNotComplete
	* @Description: TODO(查找某设备某报警类型最后一次未完成的报警信息)
	* @author wanbo
	* @date  2017年6月16日 下午6:00:44
	* @param warningId
	* @param warningType
	* @return
	*/
	public WarningInfo getWarningInfoLastNotComplete(@Param("deviceId")String deviceId,@Param("warningType")String warningType);
	
	/**
	 * @author: xiechengguang 
	 * @Title: fireWarnings   
	 * @Description: 电池欠压  
	 * @param:        
	 * @return: List<WarningInfo>      
	 * @throws
	 */
	public List<AppRespWarningVo> batteryWarnings(@Param("userId") String userId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: fireWarnings   
	 * @Description: 火灾报警  
	 * @param:        
	 * @return: List<WarningInfo>      
	 * @throws
	 */
	public List<AppRespWarningVo> fireWarnings(@Param("userId") String userId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: fireWarnings   
	 * @Description: 设备故障  
	 * @param:        
	 * @return: List<WarningInfo>      
	 * @throws
	 */
	public List<AppRespWarningVo> deviceFault(@Param("userId") String userId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getAllByCompanyId   
	 * @Description: 获取维保设备列表  
	 */
	public List<MaintenceListDTO> getAllByCompanyId(@Param("companyId") String companyId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: updateWarningInfoStatus   
	 * @Description: 删除报警信息记录（软删除）  
	 */
	@Update("update t_warning_info w set w.status = false where w.id = #{id}")
	public int updateWarningInfoStatus(String id);
	
	@Select("SELECT * FROM t_warning_info where id = #{id}")
	public WarningInfo findById(String id);
	
	@Select("SELECT w.*,wp.name warningDesc FROM t_warning_info w left join t_warning_protocol wp on w.warning_desc=wp.id where w.id = #{id}")
	public WarningInfoDto findWarningInfoDtoById(String id);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getHandleInfo   
	 * @Description: 根据id查看维保详细  
	 */
	public WarningHandleDTO getHandleInfo(@Param("id") String id);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getHandleFiles   
	 * @Description: 获取维保处理文件  
	 */
	public String[] getHandleFiles(@Param("id") String id);
	
	/**
	 * @author: xiechengguang 
	 * @Title: searchDeviceMaintences   
	 * @Description: 根据条件查询搜索维保设备列表  
	 */
	public List<MaintenceListDTO> searchDeviceMaintences(DeviceRequestProtocol params);
	
	/**
	 * @author: xiechengguang 
	 * @Title: exportMaintencByIds   
	 * @Description: 根据ids获取导出excel数据  
	 */
	public List<MaintenceListDTO> exportMaintencByIds(@Param("ids") String[] ids);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getDetailById   
	 * @Description: TODO  
	 * @param:        
	 * @return: AppWarningInfoVo      
	 * @throws
	 */
	public AppWarningInfoVo getDetailById(@Param("id") String id);
	
	/**
	 * @author: xiechengguang 
	 * @Title: countFireAlarm   
	 * @Description: 统计火灾报警  
	 * @param:        
	 * @return: int      
	 * @throws
	 */
	public int countFireAlarm(@Param("companyId") String companyId, @Param("companyIds") List<String> companyIds);
	
	/**
	 * @author: xiechengguang 
	 * @Title: countDeviceFault   
	 * @Description: 统计故障报警  
	 * @param:        
	 * @return: int      
	 * @throws
	 */
	public int countDeviceFault(@Param("companyId") String companyId, @Param("companyIds") List<String> companyIds);
	
	
	
}
